/*!
 * \file depth_first_visitor_adapter.cc
 *
 * \brief Implementations for the depth first visitor adapter for the AST
 *
 * \date Started: 5/17/2010
 * \date Last Modified: 7/27/2010
 * \authors Ian Craig
 */

#include <iegenlib/iegenlib.h>

namespace iegenlib{

/************DepthFirstAdapterVisitor****/
void DepthFirstVisitorAdapter::VarTupleCase(VarTuple* node){
  this->VarTupleIn(node);
  for(list<VarExp*>::iterator itr = node->begin(); itr != node->end(); ++itr){
    (*itr)->apply(this);
  }
  this->VarTupleOut(node);
}

void DepthFirstVisitorAdapter::ConjunctionCase(Conjunction* node){
  this->ConjunctionIn(node);
  if(node->getOutVars()==NULL){
    node->applyVars(this);
  }
  else{
    node->applyInVars(this);
    node->applyOutVars(this);
  }
  for(list<Constraint*>::iterator itr = node->begin(); itr != node->end(); ++itr){
    (*itr)->apply(this);
  }
  this->ConjunctionOut(node);
}

void DepthFirstVisitorAdapter::FuncExpCase(FuncExp* node){
  this->FuncExpIn(node);
  for(list<NormExp*>::iterator itr = node->begin(); itr != node->end(); ++itr){
    (*itr)->apply(this);
  }
  this->FuncExpOut(node);
}

void DepthFirstVisitorAdapter::NormExpCase(NormExp* node){
  this->NormExpIn(node);
  for(list<Expression*>::iterator itr = node->begin(); itr != node->end(); ++itr){
    (*itr)->apply(this);
  }
  this->NormExpOut(node);
}

void DepthFirstVisitorAdapter::EqualityCase(Equality* node){
  this->EqualityIn(node);
  node->applyExp(this);
  this->EqualityOut(node);
}

void DepthFirstVisitorAdapter::InequalityCase(Inequality* node){
  this->InequalityIn(node);
  node->applyExp(this);
  this->InequalityOut(node);
}

void DepthFirstVisitorAdapter::PresSetCase(PresSet* node){
  this->PresSetIn(node);
  node->applyConjunct(this);
  this->PresSetOut(node);
}

void DepthFirstVisitorAdapter::PresRelationCase(PresRelation* node){
  this->PresRelationIn(node);
  node->applyConjunct(this);
  this->PresRelationOut(node);
}
/****************************************/

}//end namespace iegenlib
